package week05;

import java.util.Arrays;
import java.util.Scanner;

class PersonSortable implements Comparable{
	private String name;
	private int age;
	PersonSortable(String name,int age) {
		this.name = name;
		this.age = age;
	}
	public int compareTo(Object o) {
		PersonSortable s = (PersonSortable)(o);
		if(name.equals(s.name)) {
			return age - s.age;
		}
		return name.compareTo(s.name);
	}

	public String toString() {
		return name+"-"+age;
	}
}
public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		PersonSortable[] Per = new PersonSortable[n];
		for(int i = 0;i<n;i++) {
			Per[i] = new PersonSortable(in.next(),in.nextInt());
		}
		Arrays.sort(Per);
		for (PersonSortable personSortable : Per) {
			System.out.println(personSortable.toString());;
		}
		System.out.println(Arrays.toString(PersonSortable.class.getInterfaces()));
	}
}